﻿package 
{
	//import com.citrusengine.core.CitrusEngine;
	import com.citrusengine.core.CitrusEngine;
	import flash.display.Sprite;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import State.GameState;
	import State.MainMenuState;
	import State.UpgradeState;
	
	/**
	 * ...
	 * @author ...
	 */
	public class Main extends CitrusEngine 
	{
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
			
			super();
			
			PlayerRecords.loadData();
			stage.scaleMode = StageScaleMode.NO_SCALE;
			//stage.quality = "low";
			
			state = new MainMenuState();
			
			//COMMENT OUT WHEN RELEASING GAME
			this.console.enabled = true; 
			this.console.addCommand("haxx", applyCheat); // code: "haxx <cheatcode>"
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			
			
		}
		
		private function applyCheat(cheat:String):void
		{
			if (cheat == "greedisgood")
				PlayerUpgrades.playerCoins = 99999;
			else if (cheat == "elevator")
				GameState(state).setElevatorSpeed(30);
			else if (cheat == "lives")
				GameState(state).hero.life = 99;
			else if (cheat == "alone")
				GameState(state)._currSpawn = 99999;
			else if (cheat == "resetdata")
				PlayerRecords.deleteData();
			else if (cheat == "level2")	
				state = new GameState(2);
			else if (cheat == "level3")	
				state = new GameState(3);
			else if (cheat == "level4")	
				state = new GameState(4);
			else if (cheat == "demo")
				PlayerUpgrades.playerCoins = 999;
		}
		
		public function startGame():void
		{
			state = GameState(1);
		}
	}
	
}